package com.health.personal.api.factory;

import com.health.common.core.domain.R;
import com.health.personal.api.RemotePersonalService;
import com.health.personal.api.model.po.TDoctorPo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 文件服务降级处理
 *
 * @author health
 */
@Component
public class RemotePersonalFallbackFactory implements FallbackFactory<RemotePersonalService>
{
    private static final Logger log = LoggerFactory.getLogger(RemotePersonalFallbackFactory.class);

    @Override
    public RemotePersonalService create(Throwable throwable) {
        log.error("日志服务调用失败:{}", throwable.getMessage());
        return new RemotePersonalService() {
            @Override
            public R<TDoctorPo> login(String email) {
                return R.fail("获取用户失败:" + throwable.getMessage());
            }
        };
    }
}
